from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

driver = webdriver.Edge()
driver.get(r'file:///D:/QQ(%E6%96%B0%E7%89%88)/%E6%96%87%E4%BB%B6/alert.html')
driver.maximize_window()
sleep(2)
driver.find_element(By.ID,'button').click()
sleep(1)
# 处理alter弹窗 accept确认 dismiss取消
alert = driver.switch_to.alert
alert.accept()

sleep(3)